{
  "properties" : { },
  "id" : "42a8968318e64d878af5a48baa72d811",
  "script" : null,
  "groupId" : "1662294e27c44d22ad9cca536617efe7",
  "name" : "查询下发结果",
  "createTime" : 1727071186308,
  "updateTime" : 1726813524571,
  "lock" : "0",
  "createBy" : "ndmp",
  "updateBy" : "ndmp",
  "path" : "listTemplateRs",
  "method" : "POST",
  "parameters" : [ ],
  "options" : [ ],
  "requestBody" : "{\"host\":\"\",\"deviceName\":\"\",\"templateName\":\"\",\"current\":1,\"size\":30}",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"status\": 200,\n    \"message\": \"success\",\n    \"data\": {\n        \"total\": 3,\n        \"current\": 1,\n        \"size\": 30,\n        \"records\": [\n            {\n                \"id\": \"1836672469146382336\",\n                \"deviceid\": \"D1243852758798873183\",\n                \"deviceName\": \"SN1.R2\",\n                \"host\": \"4.61.0.3\",\n                \"templateid\": \"1816005220194414594\",\n                \"templateName\": \"查看设备版本\",\n                \"finishCmdRequest\": \"\\\"terminal length 0 \\\\r\\\\n\\\"\\r\\n\\\"dis version\\\"\",\n                \"cmdResponse\": \"\\r\\r\\n******************************************************************************\\r\\r\\n* Copyright (c) 2004-2021 New H3C Technologies Co., Ltd. All rights reserved.*\\r\\r\\n* Without the owner's prior written consent,                                 *\\r\\r\\n* no decompiling or reverse-engineering shall be allowed.                    *\\r\\r\\n******************************************************************************\\r\\r\\n\\r\\r\\n<SN1.R2>terminal length 0 \\r\\r\\n                 ^\\r\\r\\n % Unrecognized command found at '^' position.\\r\\r\\n<SN1.R2>\\r\\r\\n<SN1.R2>\\r\\r\\n<SN1.R2>\\r\\r\\n<SN1.R2>dis version\\r\\r\\nH3C Comware Software, Version 7.1.064, Release 0427P22\\r\\r\\nCopyright (c) 2004-2021 New H3C Technologies Co., Ltd. All rights reserved.\\r\\r\\nH3C MSR36-20 uptime is 0 weeks, 6 days, 21 hours, 33 minutes\\r\\r\\nLast reboot reason: User reboot\\r\\r\\nBoot image: flash:/msr36-cmw710-boot-r0424p22.bin\\r\\r\\nBoot image version: 7.1.064, Release 0427P22\\r\\r\\n  Compiled Mar 16 2021 15:00:00\\r\\r\\nBoot image: flash:/msr36-cmw710-system-r0424p22.bin\\r\\r\\nBoot image version: 7.1.064, Release 0427P22\\r\\r\\n  Compiled Mar 16 2021 15:00:00\\r\\r\\n\\r\\r\\nCPU ID: 0x2\\r\\r\\n384M bytes DDR3 SDRAM Memory\\r\\r\\n1024M bytes Flash Memory\\r\\r\\nPCB               Version:  2.0\\r\\r\\nCPLD              Version:  1.0\\r\\r\\nBasic    BootWare Version:  1.42\\r\\r\\nExtended BootWare Version:  1.42\\r\\r\\n\\r\\r\\n<SN1.R2>\\r\\r\\n<SN1.R2\",\n                \"createTime\": \"2024-09-19 15:40:58\",\n                \"rowId\": \"1\",\n                \"cmdRequestListStr\": [\n                    \"\\\"terminal length 0 \\\\r\\\\n\\\"\",\n                    \"\\\"dis version\\\"\"\n                ]\n            },\n            {\n                \"id\": \"1836672122768175104\",\n                \"deviceid\": \"D1243852758798873183\",\n                \"deviceName\": \"SN1.R2\",\n                \"host\": \"4.61.0.3\",\n                \"templateid\": \"1816005220194414594\",\n                \"templateName\": \"查看设备版本\",\n                \"finishCmdRequest\": \"\\\"terminal length 0 \\\\r\\\\n\\\"\\r\\n\\\"dis version\\\"\",\n                \"cmdResponse\": \"\\r\\r\\n******************************************************************************\\r\\r\\n* Copyright (c) 2004-2021 New H3C Technologies Co., Ltd. All rights reserved.*\\r\\r\\n* Without the owner's prior written consent,                                 *\\r\\r\\n* no decompiling or reverse-engineering shall be allowed.                    *\\r\\r\\n******************************************************************************\\r\\r\\n\\r\\r\\n<SN1.R2>terminal length 0 \\r\\r\\n                 ^\\r\\r\\n % Unrecognized command found at '^' position.\\r\\r\\n<SN1.R2>\\r\\r\\n<SN1.R2>\\r\\r\\n<SN1.R2>\\r\\r\\n<SN1.R2>dis version\\r\\r\\nH3C Comware Software, Version 7.1.064, Release 0427P22\\r\\r\\nCopyright (c) 2004-2021 New H3C Technologies Co., Ltd. All rights reserved.\\r\\r\\nH3C MSR36-20 uptime is 0 weeks, 6 days, 21 hours, 32 minutes\\r\\r\\nLast reboot reason: User reboot\\r\\r\\nBoot image: flash:/msr36-cmw710-boot-r0424p22.bin\\r\\r\\nBoot image version: 7.1.064, Release 0427P22\\r\\r\\n  Compiled Mar 16 2021 15:00:00\\r\\r\\nBoot image: flash:/msr36-cmw710-system-r0424p22.bin\\r\\r\\nBoot image version: 7.1.064, Release 0427P22\\r\\r\\n  Compiled Mar 16 2021 15:00:00\\r\\r\\n\\r\\r\\nCPU ID: 0x2\\r\\r\\n384M bytes DDR3 SDRAM Memory\\r\\r\\n1024M bytes Flash Memory\\r\\r\\nPCB               Version:  2.0\\r\\r\\nCPLD              Version:  1.0\\r\\r\\nBasic    BootWare Version:  1.42\\r\\r\\nExtended BootWare Version:  1.42\\r\\r\\n\\r\\r\\n<SN1.R2>\\r\\r\\n<SN1.R2\",\n                \"createTime\": \"2024-09-19 15:40:36\",\n                \"rowId\": \"2\",\n                \"cmdRequestListStr\": [\n                    \"\\\"terminal length 0 \\\\r\\\\n\\\"\",\n                    \"\\\"dis version\\\"\"\n                ]\n            },\n            {\n                \"id\": \"1836671368963665920\",\n                \"deviceid\": \"D1243852758798873183\",\n                \"deviceName\": \"SN1.R2\",\n                \"host\": \"4.61.0.3\",\n                \"templateid\": \"1816005220194414594\",\n                \"templateName\": \"查看设备版本\",\n                \"finishCmdRequest\": \"\\\"terminal length 0 \\\\r\\\\n\\\"\\r\\n\\\"dis version\\\"\",\n                \"cmdResponse\": \"\\r\\r\\n******************************************************************************\\r\\r\\n* Copyright (c) 2004-2021 New H3C Technologies Co., Ltd. All rights reserved.*\\r\\r\\n* Without the owner's prior written consent,                                 *\\r\\r\\n* no decompiling or reverse-engineering shall be allowed.                    *\\r\\r\\n******************************************************************************\\r\\r\\n\\r\\r\\n<SN1.R2>terminal length 0 \\r\\r\\n                 ^\\r\\r\\n % Unrecognized command found at '^' position.\\r\\r\\n<SN1.R2>\\r\\r\\n<SN1.R2>\\r\\r\\n<SN1.R2>\\r\\r\\n<SN1.R2>dis version\\r\\r\\nH3C Comware Software, Version 7.1.064, Release 0427P22\\r\\r\\nCopyright (c) 2004-2021 New H3C Technologies Co., Ltd. All rights reserved.\\r\\r\\nH3C MSR36-20 uptime is 0 weeks, 6 days, 21 hours, 32 minutes\\r\\r\\nLast reboot reason: User reboot\\r\\r\\nBoot image: flash:/msr36-cmw710-boot-r0424p22.bin\\r\\r\\nBoot image version: 7.1.064, Release 0427P22\\r\\r\\n  Compiled Mar 16 2021 15:00:00\\r\\r\\nBoot image: flash:/msr36-cmw710-system-r0424p22.bin\\r\\r\\nBoot image version: 7.1.064, Release 0427P22\\r\\r\\n  Compiled Mar 16 2021 15:00:00\\r\\r\\n\\r\\r\\nCPU ID: 0x2\\r\\r\\n384M bytes DDR3 SDRAM Memory\\r\\r\\n1024M bytes Flash Memory\\r\\r\\nPCB               Version:  2.0\\r\\r\\nCPLD              Version:  1.0\\r\\r\\nBasic    BootWare Version:  1.42\\r\\r\\nExtended BootWare Version:  1.42\\r\\r\\n\\r\\r\\n<SN1.R2>\\r\\r\\n<SN1.R2\",\n                \"createTime\": \"2024-09-19 15:39:36\",\n                \"rowId\": \"3\",\n                \"cmdRequestListStr\": [\n                    \"\\\"terminal length 0 \\\\r\\\\n\\\"\",\n                    \"\\\"dis version\\\"\"\n                ]\n            }\n        ]\n    }\n}",
  "description" : "",
  "requestBodyDefinition" : {
    "name" : "root",
    "value" : "",
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ {
      "name" : "host",
      "value" : "4.61.0.3",
      "description" : "",
      "required" : false,
      "dataType" : "String",
      "type" : "",
      "defaultValue" : "",
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "deviceName",
      "value" : "开发环境4.61.0.3",
      "description" : "",
      "required" : false,
      "dataType" : "String",
      "type" : "",
      "defaultValue" : "",
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "templateName",
      "value" : "华三路由器巡检命令",
      "description" : "",
      "required" : false,
      "dataType" : "String",
      "type" : "",
      "defaultValue" : "",
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "beginTime",
      "value" : "2024-08-20 00:00:00",
      "description" : "",
      "required" : false,
      "dataType" : "String",
      "type" : "",
      "defaultValue" : "",
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "endTime",
      "value" : "2024-08-31 23:59:59",
      "description" : "",
      "required" : false,
      "dataType" : "String",
      "type" : "",
      "defaultValue" : "",
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "current",
      "value" : "1",
      "description" : "",
      "required" : false,
      "dataType" : "Integer",
      "type" : "",
      "defaultValue" : "",
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "size",
      "value" : "30",
      "description" : "",
      "required" : false,
      "dataType" : "Integer",
      "type" : "",
      "defaultValue" : "",
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    } ]
  },
  "responseBodyDefinition" : {
    "name" : "",
    "value" : "",
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : null,
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ {
      "name" : "status",
      "value" : "200",
      "description" : "",
      "required" : false,
      "dataType" : "Integer",
      "type" : null,
      "defaultValue" : "",
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "message",
      "value" : "success",
      "description" : "",
      "required" : false,
      "dataType" : "String",
      "type" : null,
      "defaultValue" : "",
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "data",
      "value" : "",
      "description" : "",
      "required" : false,
      "dataType" : "Object",
      "type" : null,
      "defaultValue" : "",
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ {
        "name" : "total",
        "value" : "3",
        "description" : "",
        "required" : false,
        "dataType" : "Integer",
        "type" : null,
        "defaultValue" : "",
        "validateType" : "",
        "error" : "",
        "expression" : "",
        "children" : [ ]
      }, {
        "name" : "current",
        "value" : "1",
        "description" : "",
        "required" : false,
        "dataType" : "Integer",
        "type" : null,
        "defaultValue" : "",
        "validateType" : "",
        "error" : "",
        "expression" : "",
        "children" : [ ]
      }, {
        "name" : "size",
        "value" : "30",
        "description" : "",
        "required" : false,
        "dataType" : "Integer",
        "type" : null,
        "defaultValue" : "",
        "validateType" : "",
        "error" : "",
        "expression" : "",
        "children" : [ ]
      }, {
        "name" : "records",
        "value" : "",
        "description" : "",
        "required" : false,
        "dataType" : "Array",
        "type" : null,
        "defaultValue" : "",
        "validateType" : "",
        "error" : "",
        "expression" : "",
        "children" : [ {
          "name" : "",
          "value" : "",
          "description" : "",
          "required" : false,
          "dataType" : "Object",
          "type" : null,
          "defaultValue" : null,
          "validateType" : "",
          "error" : "",
          "expression" : "",
          "children" : [ {
            "name" : "id",
            "value" : "1836672469146382336",
            "description" : "",
            "required" : false,
            "dataType" : "String",
            "type" : null,
            "defaultValue" : null,
            "validateType" : "",
            "error" : "",
            "expression" : "",
            "children" : [ ]
          }, {
            "name" : "deviceid",
            "value" : "D1243852758798873183",
            "description" : "",
            "required" : false,
            "dataType" : "String",
            "type" : null,
            "defaultValue" : null,
            "validateType" : "",
            "error" : "",
            "expression" : "",
            "children" : [ ]
          }, {
            "name" : "deviceName",
            "value" : "SN1.R2",
            "description" : "",
            "required" : false,
            "dataType" : "String",
            "type" : null,
            "defaultValue" : null,
            "validateType" : "",
            "error" : "",
            "expression" : "",
            "children" : [ ]
          }, {
            "name" : "host",
            "value" : "4.61.0.3",
            "description" : "",
            "required" : false,
            "dataType" : "String",
            "type" : null,
            "defaultValue" : null,
            "validateType" : "",
            "error" : "",
            "expression" : "",
            "children" : [ ]
          }, {
            "name" : "templateid",
            "value" : "1816005220194414594",
            "description" : "",
            "required" : false,
            "dataType" : "String",
            "type" : null,
            "defaultValue" : null,
            "validateType" : "",
            "error" : "",
            "expression" : "",
            "children" : [ ]
          }, {
            "name" : "templateName",
            "value" : "查看设备版本",
            "description" : "",
            "required" : false,
            "dataType" : "String",
            "type" : null,
            "defaultValue" : null,
            "validateType" : "",
            "error" : "",
            "expression" : "",
            "children" : [ ]
          }, {
            "name" : "finishCmdRequest",
            "value" : "\"terminal length 0 \\r\\n\"\r\n\"dis version\"",
            "description" : "",
            "required" : false,
            "dataType" : "String",
            "type" : null,
            "defaultValue" : null,
            "validateType" : "",
            "error" : "",
            "expression" : "",
            "children" : [ ]
          }, {
            "name" : "cmdResponse",
            "value" : "\r\r\n******************************************************************************\r\r\n* Copyright (c) 2004-2021 New H3C Technologies Co., Ltd. All rights reserved.*\r\r\n* Without the owner's prior written consent,                                 *\r\r\n* no decompiling or reverse-engineering shall be allowed.                    *\r\r\n******************************************************************************\r\r\n\r\r\n<SN1.R2>terminal length 0 \r\r\n                 ^\r\r\n % Unrecognized command found at '^' position.\r\r\n<SN1.R2>\r\r\n<SN1.R2>\r\r\n<SN1.R2>\r\r\n<SN1.R2>dis version\r\r\nH3C Comware Software, Version 7.1.064, Release 0427P22\r\r\nCopyright (c) 2004-2021 New H3C Technologies Co., Ltd. All rights reserved.\r\r\nH3C MSR36-20 uptime is 0 weeks, 6 days, 21 hours, 33 minutes\r\r\nLast reboot reason: User reboot\r\r\nBoot image: flash:/msr36-cmw710-boot-r0424p22.bin\r\r\nBoot image version: 7.1.064, Release 0427P22\r\r\n  Compiled Mar 16 2021 15:00:00\r\r\nBoot image: flash:/msr36-cmw710-system-r0424p22.bin\r\r\nBoot image version: 7.1.064, Release 0427P22\r\r\n  Compiled Mar 16 2021 15:00:00\r\r\n\r\r\nCPU ID: 0x2\r\r\n384M bytes DDR3 SDRAM Memory\r\r\n1024M bytes Flash Memory\r\r\nPCB               Version:  2.0\r\r\nCPLD              Version:  1.0\r\r\nBasic    BootWare Version:  1.42\r\r\nExtended BootWare Version:  1.42\r\r\n\r\r\n<SN1.R2>\r\r\n<SN1.R2",
            "description" : "",
            "required" : false,
            "dataType" : "String",
            "type" : null,
            "defaultValue" : null,
            "validateType" : "",
            "error" : "",
            "expression" : "",
            "children" : [ ]
          }, {
            "name" : "createTime",
            "value" : "2024-09-19 15:40:58",
            "description" : "",
            "required" : false,
            "dataType" : "String",
            "type" : null,
            "defaultValue" : null,
            "validateType" : "",
            "error" : "",
            "expression" : "",
            "children" : [ ]
          }, {
            "name" : "rowId",
            "value" : "1",
            "description" : "",
            "required" : false,
            "dataType" : "String",
            "type" : null,
            "defaultValue" : null,
            "validateType" : "",
            "error" : "",
            "expression" : "",
            "children" : [ ]
          }, {
            "name" : "cmdRequestListStr",
            "value" : "",
            "description" : "",
            "required" : false,
            "dataType" : "Array",
            "type" : null,
            "defaultValue" : null,
            "validateType" : "",
            "error" : "",
            "expression" : "",
            "children" : [ {
              "name" : "",
              "value" : "\"terminal length 0 \\r\\n\"",
              "description" : "",
              "required" : false,
              "dataType" : "String",
              "type" : null,
              "defaultValue" : null,
              "validateType" : "",
              "error" : "",
              "expression" : "",
              "children" : [ ]
            } ]
          } ]
        } ]
      } ]
    } ]
  }
}
================================
import log;
var vo = body
var sql = """
   SELECT
        sci.id,
        dev.id deviceId,
        CASE
        WHEN dev.device_alias IS NOT NULL THEN
        device_alias ELSE device_name
        END device_name ,
        dev.ip host,
        ct.id templateId,
        ct.NAME template_name,
        sci.cmd finish_cmd_request,
        sci.cmd_response,
        sci.create_time
        FROM
        ssh_cmd_info sci
        LEFT JOIN ndmp_device dev ON sci.device_id = dev.ID
        LEFT JOIN cmd_template ct ON sci.template_id = ct.ID
        WHERE 1=1

        <if test="vo.deviceName != null  and vo.deviceName != ''">
            and ( dev.device_name LIKE concat('%',#{vo.deviceName},'%')
            OR dev.device_alias LIKE concat('%',#{vo.deviceName},'%')
            OR F_PINYIN(dev.device_name) LIKE UPPER( concat('%',#{vo.deviceName},'%'))
            OR F_PINYIN(dev.device_alias) LIKE UPPER( concat('%',#{vo.deviceName},'%')))
        </if>
        <if test="vo.host != null  and vo.host != ''">
            and dev.ip like concat('%', #{vo.host} ,'%')
        </if>
        <if test="vo.templateName != null  and vo.templateName != ''">
            and ct.NAME like concat('%', #{vo.templateName} ,'%')
        </if>
        <if test="vo.beginTime != null ">
            and sci.create_time  >=    #{vo.beginTime}
        </if>

        <if test="vo.endTime != null ">
            and sci.create_time <=   #{vo.endTime}
        </if>
        order by sci.create_time desc


"""

var res = db.page(sql, vo.size, vo.size * (vo.current - 1))


if (res.total > 0) {


    for (item in res.records) {

        let split = item.finishCmdRequest.split("\r\n");
        List cmdlist = new ArrayList(Arrays.asList(split));
        cmdlist.removeAll(Collections.singleton("exit"));
        item.cmdRequestListStr = cmdlist;
    }

    return res
} else {
     res.records=[]
    return res
}